package com.yuanthink.gwt.client.workplace;

import java.util.List;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.user.client.ui.Widget;
import com.yuanthink.gwt.client.eventbus.EventBus;

/**
 * 
 * @author 06peng
 *
 */
public class WorkspacePresenter {

	public interface Display {
		 void setCurrentWorkspace(ModelData config);
		 void setWorkspaces(List<ModelData> result);
		 void setAction(String action);
		 Widget getNavigator();
		 TreePanel<ModelData> getTree();
		 Widget getMainArea();
	}
	
	LayoutContainer container;
    List<ModelData> workspaces;
    EventBus eventBus;

    String currentWorkspace;
    Display display = null;
    
    public WorkspacePresenter(EventBus eventBus) {
        this.eventBus = eventBus;
    }
	
	public void bind() {
//		setCurrentWorkplace();
	}
	

	public void go(Widget container) {
        this.container = (LayoutContainer) container;
        MainWorkplaceView wkp = new MainWorkplaceView(eventBus);
        display = wkp;
        ((LayoutContainer) container).setLayout(new FitLayout());
        this.container.add(wkp);
        this.container.layout();
        bind();
    }
	
	public void setCurrentWorkplace(ModelData config) {
		display.setCurrentWorkspace(config);
	}
}
